package com.dempsey.controller;

import com.dempsey.dao.Address;
import com.dempsey.dao.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author Dempsey
 * Date 2022/1/19
 * Description
 */

@Controller
@RequestMapping("/c")
public class MyController {

    @GetMapping("/t1")
    public String test1(Double latitude, Double longitude, Model model) {
        String msg = "latitude:" + latitude + "," + "longitude:" + longitude;
        model.addAttribute("msg", msg);

        return "test";
    }

    @GetMapping("/t2")
    public String test2(Address address, Model model) {
        String msg = address.toString();
        model.addAttribute("msg", msg);

        return "test";
    }

    @PostMapping("/t3")
    public String test3(@RequestBody User user, Model model) {
        String msg = user.toString();
        model.addAttribute("msg", msg);

        return "test";
    }

}
